<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>使用$nextTick</title>
    <script src="../../js/vue.min.js"></script>
    <script src="../../js/iview.min.js"></script>
    <link rel="stylesheet" href="../../css/iview.css">
</head>
<body>
<div id="app">
    <div v-if="showDiv" id="div">这是一段文本</div>
    <button @click="getText">获取div内容</button>
</div>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            showDiv: false
        },
        methods: {
            getText: function () {
                this.showDiv = true;
                this.$nextTick(function () {
                    var text = document.getElementById("div").innerHTML;
                    console.log(text);
                })
            }
        }
    })
</script>
</body>
</html>